package org.groupg.practice.tableInfo.model;

import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

public class TableInfo {

    private String tableCode;
    private String tableName;
    private String fromDBTable;
    private List<String> wheres;
    private List<ColumnInfo> columns;

    public TableInfo() {
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", TableInfo.class.getSimpleName() + "[", "]")
                .add("tableCode='" + tableCode + "'")
                .add("tableName='" + tableName + "'")
                .add("fromDBTable='" + fromDBTable + "'")
                .add("wheres=" + wheres)
                .add("columns=" + columns)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TableInfo tableInfo = (TableInfo) o;
        return Objects.equals(getTableCode(), tableInfo.getTableCode()) && Objects.equals(getTableName(), tableInfo.getTableName()) && Objects.equals(getFromDBTable(), tableInfo.getFromDBTable()) && Objects.equals(getWheres(), tableInfo.getWheres()) && Objects.equals(getColumns(), tableInfo.getColumns());
    }

    @Override
    public int hashCode() {
        int result = Objects.hashCode(getTableCode());
        result = 31 * result + Objects.hashCode(getTableName());
        result = 31 * result + Objects.hashCode(getFromDBTable());
        result = 31 * result + Objects.hashCode(getWheres());
        result = 31 * result + Objects.hashCode(getColumns());
        return result;
    }

    public TableInfo(String tableCode, String tableName, String fromDBTable, List<String> wheres, List<ColumnInfo> columns) {
        this.tableCode = tableCode;
        this.tableName = tableName;
        this.fromDBTable = fromDBTable;
        this.wheres = wheres;
        this.columns = columns;
    }

    public String getTableCode() {
        return tableCode;
    }

    public void setTableCode(String tableCode) {
        this.tableCode = tableCode;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getFromDBTable() {
        return fromDBTable;
    }

    public void setFromDBTable(String fromDBTable) {
        this.fromDBTable = fromDBTable;
    }

    public List<String> getWheres() {
        return wheres;
    }

    public void setWheres(List<String> wheres) {
        this.wheres = wheres;
    }

    public List<ColumnInfo> getColumns() {
        return columns;
    }

    public void setColumns(List<ColumnInfo> columns) {
        this.columns = columns;
    }
}
